Code:
void MakeVector(const vec3_t ain, vec3_t vout)
{
   vout[0] = (float)(-cos(ain[0] * 3.141592/180) * -cos(ain[1] * 3.141592/180));
   vout[1] = (float)(sin(ain[1] * 3.141592/180) * cos(ain[0] * 3.141592/180));cos(ain[0] * 3.141592/180);
   vout[2] = (float)-sin(ain[0] * 3.141592/180);
}

void VectorRotateX(const vec3_t in, float angle, vec3_t out)
{
   out[0] = in[0];
   out[1] = (float)cos(angle * 3.141592/180)*in[1] - sin(angle * 3.141592/180)*in[2];
   out[2] = (float)sin(angle * 3.141592/180)*in[1] + cos(angle * 3.141592/180)*in[2];   
}

void VectorRotateY(const vec3_t in, float angle, vec3_t out)
{
   out[0] = (float)cos(angle * 3.141592/180)*in[0] + sin(angle * 3.141592/180)*in[2];
   out[1] = in[1];
   out[2] = (float)-sin(angle * 3.141592/180)*in[0] + cos(angle * 3.141592/180)*in[2];
}
//===================================================================================

void VectorRotateZ(const vec3_t in, float angle, vec3_t out)
{
   out[0] = (float)cos(angle * 3.141592/180)*in[0] - sin(angle * 3.141592/180)*in[1];
   out[1] = (float)sin(angle * 3.141592/180)*in[0] + cos(angle * 3.141592/180)*in[1];
   out[2] = in[2];
}

int NewCalcScreen(float* in, float* out)
{
   vec3_t aim;
   vec3_t newaim;
   vec3_t view;
   vec3_t tmp;
   float num;
   if(!in||!out){ return false; }
   VectorSubtract(in,mainViewOrigin,aim);   
   MakeVector(mainViewAngles,view);   
   if (VectorAngle(view,aim) > (fCurrentFOV/1.8))
   {
      return false;
   }      
   VectorRotateZ(aim,-mainViewAngles[1],newaim);
   VectorRotateY(newaim,-mainViewAngles[0],tmp);
   VectorRotateX(tmp,-mainViewAngles[2],newaim);
   if (newaim[0] <= 0)
   {
      return false;
   }
   if(fCurrentFOV==0.0){ return false; }
   num = ((displayCenterX/newaim[0])*(120.0/fCurrentFOV - 1.0/3.0)); // 1.0/3.0
   out[0] = displayCenterX - num*newaim[1];
   out[1] = displayCenterY - num*newaim[2];
   BOUND_VALUE(out[0],0,displayCenterX*2);
   BOUND_VALUE(out[1],0,displayCenterY*2);
   return true;

}


my old rendition of calcscreen.
same thing, just all packed.